package fileHandling;

import com.jme.renderer.ColorRGBA;

import logic.nodes.nodeSettings.Settings;

public class TextureSettings extends Settings {
	
	private static final String AMBIENT = "amb_";
	private static final String DIFFUSE = "dif_";
	private static final String SPECULAR = "spe_";
	
	private static final String RED = "red";
	private static final String BLUE =  "blue";
	private static final String GREEN = "green";
	
	private static final String SHININESS = "shine";
	
	private static final float NO_SHINE = -1f;
	
	private ColorRGBA ambient, diffuse, specular;
	private float shininess;
	
	public TextureSettings(Settings settings) {
		super(settings);
		shininess = NO_SHINE;
	}
	
	public float getShininess() {
		if(shininess == NO_SHINE) shininess = Float.valueOf(getValueOf(SHININESS)).floatValue();
		return shininess;
	}
	
	public ColorRGBA getAmbientColor() {
		if(ambient == null) ambient = createNewColor(AMBIENT);
		return ambient;
	}
	
	public ColorRGBA getDiffuseColor() {
		if(diffuse == null) diffuse = createNewColor(DIFFUSE);
		return diffuse;
	}
	
	public ColorRGBA getSpecularColor() {
		if(specular == null) specular = createNewColor(SPECULAR);
		return specular;
	}
	
	private ColorRGBA createNewColor(String prefix) {
		float r = Float.valueOf(getValueOf(prefix + RED)).floatValue();
		float g = Float.valueOf(getValueOf(prefix + GREEN)).floatValue();
		float b = Float.valueOf(getValueOf(prefix + BLUE)).floatValue();
		return new ColorRGBA(r, g, b, 1f);
	}
}